<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>添加</title>
		<style>
			@charset "UTF-8";
			
			body {
				margin: 10px 10px 10px 10px !important;
				background: #f2f2f2;
			}
			
			.page_container {
				border: 1px solid #f2f2f2;
				border-radius: 5px;
				background-color: #ffffff;
				padding: 20px;
			}
			
			.page_container .zhongxian {
				opacity: 0.15;
			}
			
			.page_container .atitle {
				margin-left: 20px;
				padding: 0 10px;
				font-size: 20px;
				font-weight: 300;
			}
			.layui-layer-dialog .layui-layer-setwin{
				display: none;
			}
			.finder-image{
				width: 100%;
			}
			.finder-image-preview{
			float: left;
			max-width: 400px;
			background: #eee;
			overflow: hidden;
			position: relative;
			color: #000;
			cursor:pointer;
			min-width: 200px;
			margin-right: 8px;
			}
			.finder-image-preview .image-preview{
			color: #000;
			line-height: 200px;
			text-align: center;
			}
			.finder-image-button{
			width:20px;
			min-height:200px;
			float: left;
			background: #fff;
			overflow: hidden;
			padding-left: 1px;
			}
			.clone-one-image:hover{
				color: #FF0000;
			}
			.preview-text{
				padding-top: 3px;
				width: 100%; 
				overflow: hidden;
				background: #fff;
			}
			.preview-text-input{
				width: 100%;
				background: #fff;
				height: 28px;
				border: none;
			}
			.preview-text-input:hover{
				background-color: #d2d2d2;
			}
			.required{
				font-size: 16px;
				color: #f00;
				font-family: Tahoma;
				vertical-align: middle;
				margin-right: 2px;
				font-weight: 400;color: #f00;
				font-weight: 400;margin-right: 5px;
			}
			.layui-anim {
				z-index: 9999 !important;
			}
		</style>
		<link rel="stylesheet" href="../../utils/layui/css/layui.css">
		<script type="text/javascript" src="../../utils/ueditor/ueditor.config.js"></script>
		<script type="text/javascript" src="../../utils/ueditor/ueditor.all.min.js"></script>
		<script type="text/javascript" src="../../utils/ueditor/lang/zh-cn/zh-cn.js"></script>
		
	</head>
	<body>
		<div class="page_container"  id="view">
			
			<form class="layui-form" action=""  method="post"  onsubmit="return false;">
				<input id="_method" type="hidden" name="_method" value="PUT">
				<input type="hidden" name="_method_" id="_method_" value="" />
				<input type="hidden" name="toolbar" id="toolbar" value="row" />
			 	{{#  arr_foreach(d.table_struct.field, function(key, value){ }}
				
					{{#  if(value.input_type == 'hidden'){ }}
						<input data-label="{{value.label}}" id="{{value.field}}" type="hidden" name="{{value.field}}" maxlength="" placeholder="请输入{{value.label}}" autocomplete="off" class="layui-input" maxlength="{{value.input_maxlength}}" value="{{input_default(value.default)}}">
						
					{{#  }else if(value.input_type == 'password'){ }}
					    <div class="layui-form-item">
					      <label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
					      <div class="layui-input-block">
					        <input data-label="{{value.label}}" type="password" id="{{value.field}}" name="{{value.field}}" placeholder="请输入{{value.label}}" autocomplete="off" class="layui-input" lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}" value="{{input_default(value.default)}}">
					      </div>
					    </div>
						
					{{#  }else if(value.input_type == 'radio'){ }}
					    <!--得保证value是有序数组--->
					    <div class="layui-form-item">
					      <label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
					      <div class="layui-input-block">
							  {{#  arr_foreach(value.value, function(k1, v1){ }}
								  {{#  if(k1 == value.default){ }}
									<input data-label="{{value.label}}" type="radio" name="{{value.field}}" value="{{k1}}" title="{{v1}}" checked="" lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}">
								  {{# }else{ }}   
									<input data-label="{{value.label}}" type="radio" name="{{value.field}}" value="{{k1}}" title="{{v1}}" lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}">
								  {{# } }} 
							  {{#  }); }}
					      </div>
					    </div>	
					{{#  }else if(value.input_type == 'checkbox'){ }}
					    <!--得保证value是有序数组--->
					    <div class="layui-form-item">
					      <label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
					      <div class="layui-input-block">
							  {{#  arr_foreach(value.value, function(k1, v1){ }}
								  {{#  if(in_array(k1, value.default)){ }}
									<input lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}" data-label="{{value.label}}" type="checkbox" name="{{value.field}}[]" value="{{k1}}" title="{{v1}}" checked="">
								  {{# }else{ }}   
									<input lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}" data-label="{{value.label}}" type="checkbox" name="{{value.field}}[]" value="{{k1}}" title="{{v1}}">
								  {{# } }} 
							  {{#  }); }}
					      </div>
					    </div>		
					{{#  }else if(value.input_type == 'number'){ }}
					    <!--得保证value是有序数组--->
					    <div class="layui-form-item">
					      <label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
					      <div class="layui-input-block">
							  <input data-label="{{value.label}}" type="number" id="{{value.field}}" name="{{value.field}}"  maxlength="{{value.input_maxlength}}"  placeholder="请输入{{value.label}}" autocomplete="off" class="layui-input" lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}" value="{{input_default(value.default)}}">
					      </div>
					    </div>	
					{{#  }else if(value.input_type == 'float'){ }}
					    <!--得保证value是有序数组--->
					    <div class="layui-form-item">
					      <label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
					      <div class="layui-input-block">
							  <input data-label="{{value.label}}" type="number" id="{{value.field}}" name="{{value.field}}"  maxlength="{{value.input_maxlength}}"  min="{{value.input_min}}"  step="{{value.input_step}}"  placeholder="请输入{{value.label}}" autocomplete="off" class="layui-input" lay-verify="{{#  if(value.null == 'no'){ }}required|number{{#  } }}" value="{{input_default(value.default)}}">
					      </div>
					    </div>		
					{{#  }else if(value.input_type == 'select'){ }}
					    <!--得保证value是有序数组--->
					    <div class="layui-form-item">
					      <label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
					      <div class="layui-input-block">
							  <select data-label="{{value.label}}" name="{{value.field}}" id="{{value.field}}" lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}">
							    <option value="">请选择</option>
							  {{#  arr_foreach(value.value, function(k1, v1){ }}
									{{var_dump(is_avoidBrowser(v1))}}
									{{#  if(is_avoidBrowser(v1)){ }}
											{{#  if(v1.key == value.default){ }}
												<option value="{{v1.key}}" selected="">{{v1.val}}</option>
											{{# }else{ }} 
												<option value="{{v1.key}}">{{v1.val}}</option>
											{{#  } }} 
									{{# }else{ }} 											
											{{#  if(k1 == value.default){ }}
											<option value="{{k1}}" selected="">{{v1}}</option>
											{{# }else{ }} 
											<option value="{{k1}}">{{v1}}</option>
											{{#  } }} 
									{{#  } }}
							  {{#  }); }}
							  </select>
					      </div>
					    </div>	
					{{#  }else if(value.input_type == 'color'){ }}
					    <div class="layui-form-item">
					      <label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
					      <div class="layui-input-block">
					        <input data-label="{{value.label}}" id="{{value.field}}" type="color" name="{{value.field}}" value="{{input_default(value.default)}}" lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}" style="height: 38px;width: 80px;" />
					      </div>
					    </div>	
					
					{{#  }else if(value.input_type == 'textarea'){ }}
					    <div class="layui-form-item">
					      <label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
					      <div class="layui-input-block">
							  <textarea data-label="{{value.label}}" id="{{value.field}}" name="{{value.field}}" placeholder="请输入{{value.label}}" class="layui-textarea" lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}">{{input_default(value.default)}}</textarea>
					      </div>
					    </div>		
					{{#  }else if(value.input_type == 'image'){ }}
					    <div class="layui-form-item">
						  <input data-label="{{value.label}}" id="validation-{{value.field}}" value="{{#  if(value.defaultObj != ''){ }}1{{# } }}"  type="text" style="display: none;"  lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}">	
					      <label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
					      <div class="layui-input-block">
							  <div class="finder-image-preview" id="finder-image-{{value.field}}" data-type="one-image">
								 
								{{#  if(value.defaultObj != ''){ }}
								<div class="clone-one-image" style="position: absolute; right: 5px; top:5px; z-index: 99;" onclick="cloneOneImage(this, '{{value.field}}');">
									  <i class="layui-icon layui-icon-close-fill" style="font-size: 24px;"></i>
								 </div>
								<!--隐藏域-->
								{{image_input(value.field, value.defaultObj)}}
								<div class="image-preview" onclick="oneImageSelect(this, '{{value.field}}');"><img alt="图片" src="{{value.defaultObj.url}}" height="200px"></div>
								<div class="preview-text" ><input readonly="readonly" title="{{value.defaultObj.original}}" class="preview-text-input" type="text" value="{{value.defaultObj.original}}"></div>
								{{# }else{ }}   
								<div class="clone-one-image" style="position: absolute; right: 5px; top:5px; z-index: 99;display: none;" onclick="cloneOneImage(this, '{{value.field}}');">
									  <i class="layui-icon layui-icon-close-fill" style="font-size: 24px;"></i>
								 </div>
								<input class="image_input"  name="{{value.field}}" value="" type="hidden"  />
								<div class="image-preview" onclick="oneImageSelect(this, '{{value.field}}');">请选择一张图片</div>
								<div class="preview-text" ></div>
								{{# } }} 
							  </div>
					      </div>
					    </div>	
					{{#  }else if(value.input_type == 'images'){ }}
					    <div class="layui-form-item">
						  <input data-label="{{value.label}}" id="validation-{{value.field}}" value="{{#  if(value.defaultObj != ''){ }}1{{# } }}"  type="text" style="display: none;"  lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}">
						  <label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
						  <div class="layui-input-block">
							  
							  <!----循环----->
							  {{#  if(value.defaultObj != ''){ }}
								  {{#  arr_foreach(value.defaultObj, function(k1, v1){ }}
								  <div class="finder-image">
									<div class="finder-image-preview" data-type="more-image">
										 <div class="clone-one-image" style="position: absolute; right: 5px; top:5px; z-index: 99;" onclick="cloneMoreImage(this, '{{value.field}}');">
											  <i class="layui-icon layui-icon-close-fill" style="font-size: 24px;"></i>
										  </div>
										{{image_input(value.field+"[]", v1)}}  
										<div class="image-preview" onclick="moreImageSelect(this, '{{value.field}}');"><img alt="图片" src="{{v1.url}}" height="200px"></div>
										<div class="preview-text" ><input readonly="readonly" title="{{v1.original}}" class="preview-text-input" type="text" value="{{v1.original}}" /></div>
									</div>
								  </div>
								  {{#  }); }}
							  {{# }else{ }}   
							  <div class="finder-image">
							  	<div class="finder-image-preview" data-type="more-image">
							  		 <div class="clone-one-image" style="position: absolute; right: 5px; top:5px; z-index: 99;display: none;" onclick="cloneMoreImage(this, '{{value.field}}');">
							  			  <i class="layui-icon layui-icon-close-fill" style="font-size: 24px;"></i>
							  		  </div>
							  		
							  		<input class="image_input"  name="{{value.field}}[]" value="" type="hidden"  />
							  		<div class="image-preview" onclick="moreImageSelect(this, '{{value.field}}');">请选择一张或多张图片</div>
							  		<div class="preview-text" ></div>
							  	</div>
							  </div>
							  {{# } }} 
								
								
						  </div>
						</div>	
						{{#  }else if(value.input_type == 'video'){ }}
						    <div class="layui-form-item">
							  <input data-label="{{value.label}}" id="validation-{{value.field}}" value="{{#  if(value.defaultObj != ''){ }}1{{# } }}"  type="text" style="display: none;"  lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}">	
							  <label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
							  <div class="layui-input-block">
									<div class="finder-image-preview" data-type="one-video">
										
										
										{{#  if(value.defaultObj != ''){ }}
										<div class="clone-one-image" style="position: absolute; right: 5px; top:5px; z-index: 99;" onclick="cloneOneImage(this, '{{value.field}}');">
											  <i class="layui-icon layui-icon-close-fill" style="font-size: 24px;"></i>
										  </div>
										
										{{image_input(value.field, value.defaultObj)}}
										<div class="image-preview" onclick="oneVideoSelect(this, '{{value.field}}');"><img alt="缩略图" src="{{value.defaultObj.thumbnail}}" height="200px"></div>
										<div class="preview-text" ><input readonly="readonly" title="{{value.defaultObj.original}}" class="preview-text-input" type="text" value="{{value.defaultObj.original}}" /></div>
										{{# }else{ }}   
										<div class="clone-one-image" style="position: absolute; right: 5px; top:5px; z-index: 99;display: none;" onclick="cloneOneImage(this, '{{value.field}}');">
											  <i class="layui-icon layui-icon-close-fill" style="font-size: 24px;"></i>
										  </div>
										
										<input class="image_input"  name="{{value.field}}" value="" type="hidden"  />
										<div class="image-preview" onclick="oneVideoSelect(this, '{{value.field}}');">请选择一个视频</div>
										<div class="preview-text" ></div>
										{{# } }} 
										
										
									</div>
							  </div>
							</div>	
						{{#  }else if(value.input_type == 'videos'){ }}
						    <div class="layui-form-item">
							  <input data-label="{{value.label}}" id="validation-{{value.field}}" value="{{#  if(value.defaultObj != ''){ }}1{{# } }}"  type="text" style="display: none;"  lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}">	
							  <label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
							  <div class="layui-input-block">
									{{#  if(value.defaultObj != ''){ }}
									
									  {{#  arr_foreach(value.defaultObj, function(k1, v1){ }}
									  <div class="finder-image">
									  	<div class="finder-image-preview" id="finder-image-{{value.field}}" data-type="more-video">
									  		 <div class="clone-one-image" style="position: absolute; right: 5px; top:5px; z-index: 99;display: none;" onclick="cloneMoreImage(this, '{{value.field}}');">
									  			  <i class="layui-icon layui-icon-close-fill" style="font-size: 24px;"></i>
									  		  </div>
									  		
									  		{{image_input(value.field+"[]", v1)}}  
									  		<div class="image-preview" onclick="moreVideoSelect(this, '{{value.field}}');"><img alt="缩略图" src="{{v1.thumbnail}}" height="200px"></div>
									  		<div class="preview-text" ><input readonly="readonly" title="{{v1.original}}" class="preview-text-input" type="text" value="{{v1.original}}" /></div>
									  	</div>
									  </div>
									  {{#  }); }}
									  
									{{# }else{ }}   
									<div class="finder-image">
										<div class="finder-image-preview" id="finder-image-{{value.field}}" data-type="more-video">
											 <div class="clone-one-image" style="position: absolute; right: 5px; top:5px; z-index: 99;display: none;" onclick="cloneMoreImage(this, '{{value.field}}');">
												  <i class="layui-icon layui-icon-close-fill" style="font-size: 24px;"></i>
											  </div>
											
											<input class="image_input"  name="{{value.field}}[]" value="" type="hidden"  />
											<div class="image-preview" onclick="moreVideoSelect(this, '{{value.field}}');">请选择一个或多个视频</div>
											<div class="preview-text" ></div>
										</div>
									</div>
									
									{{# } }} 
							  </div>
							</div>	
						{{#  }else if(value.input_type == 'audio'){ }}
						    <div class="layui-form-item">
							  <input data-label="{{value.label}}"  id="validation-{{value.field}}" value="{{#  if(value.defaultObj != ''){ }}1{{# } }}"  type="text" style="display: none;"  lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}">	
							  <label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
							  <div class="layui-input-block">
									<div>
									  <ul class="layui-tab-title" style="border: 1px solid #eee;  height:38px; overflow: hidden; width:70%;float:left;">    
										  {{#  if(value.defaultObj != ''){ }}
										  <li style="border-radius: 2px;height:26px; margin-left: 5px; margin-top:5px;line-height:1.8em;padding: 0 8px;background: #fff;color: #000;" >{{value.defaultObj.original}}
										  {{image_input(value.field, value.defaultObj)}}
										  <i class="layui-icon layui-unselect layui-tab-close" onclick="javascript:this.parentNode.parentNode.removeChild(this.parentNode);document.getElementById('validation-{{value.field}}').value='';">ဆ</i></li>
										  {{# } }} 
									  </ul>
									  <button style="float: left; width: 80px; margin-left: 5px;" type="button" class="layui-btn layui-btn-primary" onClick="oneAudioSelect(this, '{{value.field}}')">浏览</button>
									</div>
							  </div>
							</div>	
						{{#  }else if(value.input_type == 'audios'){ }}
						    <div class="layui-form-item">
							  <input data-label="{{value.label}}"  id="validation-{{value.field}}" value="{{#  if(value.defaultObj != ''){ }}1{{# } }}"  type="text" style="display: none;"  lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}">	
							  <label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
							  <div class="layui-input-block">
									<div>
									  <ul class="layui-tab-title" style="border: 1px solid #eee;  min-height:22px; height: auto; overflow: hidden; width:70%;float:left; padding: 8px;">    
									  
										{{#  if(value.defaultObj != ''){ }}
											{{table_input(value.field+"[]", value.defaultObj)}}  
										{{# } }} 
									  </ul>
									  <button style="float: left; width: 80px; margin-left: 5px;" type="button" class="layui-btn layui-btn-primary" onClick="moreAudioSelect(this, '{{value.field}}')">浏览</button>
									</div>
							  </div>
							</div>	
						{{#  }else if(value.input_type == 'document'){ }}
						    <div class="layui-form-item">
							  <input data-label="{{value.label}}" id="validation-{{value.field}}" value="{{#  if(value.defaultObj != ''){ }}1{{# } }}"  type="text" style="display: none;"  lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}">	
							  <label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
							  <div class="layui-input-block">
									<div>
									  <ul class="layui-tab-title" style="border: 1px solid #eee;  height:38px; overflow: hidden; width:70%;float:left;">    
									  {{#  if(value.defaultObj != ''){ }}
									  <li style="border-radius: 2px;height:26px; margin-left: 5px; margin-top:5px;line-height:1.8em;padding: 0 8px;background: #fff;color: #000;" >{{value.defaultObj.original}}
									  {{image_input(value.field, value.defaultObj)}}
									  <i class="layui-icon layui-unselect layui-tab-close" onclick="javascript:this.parentNode.parentNode.removeChild(this.parentNode);document.getElementById('validation-{{value.field}}').value='';">ဆ</i></li>
									  {{# } }} 
									  </ul>
									  <button style="float: left; width: 80px; margin-left: 5px;" type="button" class="layui-btn layui-btn-primary" onClick="oneDocumentSelect(this, '{{value.field}}')">浏览</button>
									</div>
							  </div>
							</div>	
						{{#  }else if(value.input_type == 'documents'){ }}
						    <div class="layui-form-item">
								<input data-label="{{value.label}}" id="validation-{{value.field}}" value="{{#  if(value.defaultObj != ''){ }}1{{# } }}"  type="text" style="display: none;"  lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}">
								<label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
								<div class="layui-input-block">
									<div>
									  <ul class="layui-tab-title" style="border: 1px solid #eee;  min-height:22px; height: auto; overflow: hidden; width:70%;float:left; padding: 8px;">    
										{{#  if(value.defaultObj != ''){ }}
											{{table_input(value.field+"[]", value.defaultObj)}}  
										{{# } }} 
									  </ul>
									  <button style="float: left; width: 80px; margin-left: 5px;" type="button" class="layui-btn layui-btn-primary" onClick="moreDocumentSelect(this, '{{value.field}}')">浏览</button>
									</div>
								</div>
							 </div>	
						{{#  }else if(value.input_type == 'date'){ }}
						    <div class="layui-form-item">
								<label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
								<div class="layui-input-block">
									<input data-label="{{value.label}}" type="text" name="{{value.field}}"  id="{{value.field}}"  placeholder="请输入{{value.label}}" autocomplete="off" class="layerdate layui-input"  lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}" value="{{input_date(value.default)}}">
								</div>
							 </div>	 
						{{#  }else if(value.input_type == 'time'){ }}
						    <div class="layui-form-item">
								<label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
								<div class="layui-input-block">
									<input data-label="{{value.label}}" type="text" name="{{value.field}}" id="{{value.field}}"  placeholder="请输入{{value.label}}" autocomplete="off" class="layertime layui-input"  lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}" value="{{input_time(value.default)}}">
								</div>
							 </div>		
						{{#  }else if(value.input_type == 'checkboxwindow'){ }}
						    <div class="layui-form-item">
							  <input data-label="{{value.label}}" id="validation-{{value.field}}" value="{{#  if(value.defaultObj != ''){ }}1{{# } }}"  type="text" style="display: none;"  lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}">
							  <label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
							  <div class="layui-input-block">
									<div>
									  <ul class="layui-tab-title" style="border: 1px solid #eee;  height:38px; overflow: hidden; width:70%;float:left;">    
										{{#  arr_foreach(value.defaultObj, function(k1, v1){ }}
										<li style="border-radius: 2px;height:26px; margin-left: 5px; margin-top:5px;line-height:1.8em;padding: 0 8px;background: #fff;color: #000;" >{{v1.title}}{{window_input(value.field+'[]', v1)}}<i class="layui-icon layui-unselect layui-tab-close" onclick="javascript:if(this.parentNode.parentNode.getElementsByTagName('li').length <= 1){document.getElementById('validation-{{value.field}}').value='';};this.parentNode.parentNode.removeChild(this.parentNode);">ဆ</i></li>
										{{#  }); }}				  
									  </ul>
									  <button style="float: left; width: 80px; margin-left: 5px;" type="button" class="layui-btn layui-btn-primary" data-valuetable="{{value.value_table}}"  data-title="{{value.label}}" onClick="moreOpenSelect(this, '{{value.field}}')">选择</button>
									</div>
							  </div>
							</div>
						{{#  }else if(value.input_type == 'radiowindow'){ }}
						    <div class="layui-form-item">
							  <input data-label="{{value.label}}" id="validation-{{value.field}}" value="{{#  if(value.defaultObj != ''){ }}1{{# } }}"  type="text" style="display: none;"  lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}">
							  <label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
							  <div class="layui-input-block">
									<div>
									  <ul class="layui-tab-title" style="border: 1px solid #eee;  height:38px; overflow: hidden; width:70%;float:left;">    								
									  {{#  if(value.defaultObj != ''){ }}
									  <li style="border-radius: 2px;height:26px; margin-left: 5px; margin-top:5px;line-height:1.8em;padding: 0 8px;background: #fff;color: #000;" >{{value.defaultObj.title}}
									  {{window_input(value.field, value.defaultObj)}}
									  <i class="layui-icon layui-unselect layui-tab-close" onclick="javascript:this.parentNode.parentNode.removeChild(this.parentNode);document.getElementById('validation-{{value.field}}').value='';">ဆ</i></li>
									  {{# } }}
									  </ul>
									  <button style="float: left; width: 80px; margin-left: 5px;" type="button" class="layui-btn layui-btn-primary" data-valuetable="{{value.value_table}}" data-title="{{value.label}}" onClick="oneOpenSelect(this, '{{value.field}}')">选择</button>
									</div>
							  </div>
							</div>	
						{{#  }else if(value.input_type == 'baidueditor'){ }}
						    <div class="layui-form-item">
							  <label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
							  <div class="layui-input-block">
									<textarea data-label="{{value.label}}" id="{{value.field}}" name="{{value.field}}" placeholder="请输入{{value.label}}" class="layui-textarea baidueditor"  style="width:100%;height:400px;" lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}">{{input_default(value.default)}}</textarea>
									
							  </div>
							</div>			
						{{#  }else if(value.input_type == 'file'){ }}
						    <div class="layui-form-item">
							  <label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
							  <div class="layui-input-block">
								  <input data-label="{{value.label}}" type="file" name="{{value.field}}" id="{{value.field}}"   placeholder="请输入{{value.label}}" autocomplete="off" class="layui-input" lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}" value="{{input_default(value.default)}}">
							  </div>
							</div>		  
					{{# }else{ }} 
					
					<div class="layui-form-item">
					  <label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
					  <div class="layui-input-block">
					    <input data-label="{{value.label}}" type="{{value.input_type}}" name="{{value.field}}" id="{{value.field}}"   placeholder="请输入{{value.label}}" autocomplete="off" class="layui-input" lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}" value="{{input_default(value.default)}}">
					  </div>
					</div>
					
					{{# } }} 
			 		
			 	{{#  }); }}
			 
			  <div class="layui-form-item">
			    <div class="layui-input-block">
			      <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
			      <button type="reset" class="layui-btn layui-btn-primary" id="fmreset">重置</button>
			    </div>
			  </div>
			</form>
			
			
				
			
		</div>


		<script src="/admin/utils/layui/layui.js" charset="utf-8"></script>
		<script src="/admin/utils/layui/config.js" charset="utf-8"></script>
		<script>
			
			
			
			window.image_input = function(key, df){
				return "<input class=\"image_input\"  name=\""+key+"\" value='"+json_encode(df)+"' type=\"hidden\"  />";
			}
			
			window.window_input = function(key, df){
				return "<input class='input-hidden' type='hidden' name='"+key+"' value='"+json_encode(df)+"' />";
			}
			window.table_input = function(key, df){
				var tbhtml = '<table class="layui-table">\
				  <thead>\
					<tr>\
						<th width="60%">文件</th>\
						<th>操作</th>\
					</tr>\
				  </thead>\
				  <tbody>';
				for(i in df){
					tbhtml += '<tr>\
							  <td>'+df[i]['original']+image_input(key, df[i])+'</td>\
							  <td><a onclick="cloneMoreDocument(this, \''+key+'\')" href="javascript:void(0)">删除</a></td>\
						  </tr>';
				}
				tbhtml += '</tbody></table>';
				return tbhtml;
			}
			
			layui.use(['layer','helper', 'laytpl', 'formbuilder', 'parsedata', 'view'], function(){
				var primary_key = parent.window.memuData.table_struct['primary_key'];
				var laytpl = layui.laytpl;
				var parsedata = layui.parsedata;
				var getTpl = document.getElementById('view').innerHTML;
				var view = document.getElementById('view');
				
				ajax_request($_GET['api']+'?_primary_='+$_GET[primary_key]+"&_method=GET", "GET", "" , function(res){
					//把值设定到表结构的默认值上
					res = res.data.data[0];
					var editMemuData = parent.window.memuData;
					for(i in editMemuData.table_struct.field){
						 editMemuData.table_struct.field[i]['default'] = res[i];
						 var json = is_json(res[i]);
						 if(json !== null && json !== false){
							 if(json.length != undefined && json.length > 0){
								 for(ii in json){
									 var jsonItem = is_json(json[ii]);
									 if(jsonItem !== false){
										 json[ii] = jsonItem;
									 }
								 }
							 }
						 	editMemuData.table_struct.field[i]['defaultObj'] = json;
							//json 可能还是一个对象
							
						 }else{
							editMemuData.table_struct.field[i]['defaultObj'] = "";
						}
					}
					data = editMemuData;
					//渲染模版	
					laytpl(getTpl).render(data, function(html){
					  view.innerHTML = html;//渲染
					  
					  //layer表单
					  layui.use(['form', 'laydate'], function(){
						  var laydate = layui.laydate;
						  var $ = layui.$;
						  var form = layui.form;
						  
						  //渲染绑定日期操作框
						  $(".layerdate").each(function(index){
						  	laydate.render({
						  	  elem: '#' + this.id //指定元素
						  	});
						  });				
						  				
						  //渲染绑定时间操作框
						  $(".layertime").each(function(index){
						  	laydate.render({
						  	  elem: '#' + this.id, //指定元素
						  	  type: 'datetime'
						  	});
						  });
						  
						  //渲染绑定百度编辑框
						  $(".baidueditor").each(function(index){
						  	var ue = UE.getEditor(this.id,{
						  		autoHeightEnabled: true,
						  		autoFloatEnabled: true
						  	});
						  });
						  
						  //验证表单
						  form.verify(window.formVerifyConf);
						  
						  //表单提交监听
						  form.on('submit(formDemo)', function(data){
						  	window.submitData = data.field;
						  	let formdata = layFormData(data, parent.window.memuData);
							//提交请求
							submit_request($_GET['api'], "POST", formdata, function(res){
								if(!is_object(res)){
									return alert(res);
								}
								let field = parent.window.memuData.table_struct.field;
								for(i in res.data){
									if(typeof(parent.window.selectObj.data[i]) != "undefined"){
										var parseFun = field[i]['input_type'];
										var parseOption = field[i]['value'];
										var item =  res.data[i];																	
										//数组value是关联数组的情况
										try{
											if(parseOption[0]['key']){
												var selectOptions = new Array();//这里就不管他妈的索引不索引的了会排序但不会丢失索引
												for(psi in parseOption){
													var rowOption = parseOption[psi];
													selectOptions[rowOption.key] = rowOption.val;
												}
												parseOption = selectOptions;
											}
										}catch(e){
											//TODO handle the exception
										}
										//、、、					
										eval('item = parsedata.'+parseFun+'(item, parseOption);');
										if(in_array(i, ['create_time', 'update_time']) && is_numeric(item) && item > 0 && parseFun == 'hidden'){
											item = formatDate(item * 1000, 'Y-M-D H:i:s');
										}
										parent.window.selectObj.data[i] = item;
									}
								}
								console.log(parent.window.selectObj.data);
								parent.window.selectObj.update(parent.window.selectObj.data);
								noticeMsg('success', "编辑成功");
								parent.layer.closeAll();
							});
						  });
						  
					  });
					});
					
				});
				
				
			});
			
		</script>
	</body>
</html>
